﻿/// <reference path="../Scripts/jquery-2.1.0.js" />

function check() {
    var result = "";

    var captcha = $("#captcha").val();
    if (captcha.length > 0) {
        //TODO:这个里写判断验证码的逻辑
    }

    //手机号码
    var telNum = $("#telNum");
    if (telNum.val().length > 0 && /\d{11}/.exec(telNum.val()) != telNum.val()) {
        result = telNum.attr("id");
        telNum.parent().parent().find(".msg").text("手机号码输入的不正确.");
    } else {
        telNum.parent().parent().find(".msg").text("");
    }

    //确认密码
    var password = $("#password");
    var confirmPassword = $("#confirmPassword");
    if (confirmPassword.val().length > 0 && password.val() != confirmPassword.val()) {
        result = confirmPassword.attr("id");
        confirmPassword.parent().parent().find(".msg").text("两次密码输入不一致.");
    } else {
        confirmPassword.parent().parent().find(".msg").text("");
    }

    //TODO:密码验证规则

    //用户名
    var userName = $("#userName");
    if (userName.val().length > 0 && /[\w\d]{2,16}/.exec(userName.val()) != userName.val()) {
        result = userName.attr("id");
        userName.parent().parent().find(".msg").text("您登陆是使用的用户ID,2至16位数字或字母组成.");
    } else {
        userName.parent().parent().find(".msg").text("");
    }

    return result;
}

function verification() {
    var id = check();
    if (id == "") return true;
    $("#" + id).focus();
    return false;
}